package com.ruoyi.web.controller.seal;

import java.util.List;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.domain.entity.SealDetail;
import com.ruoyi.system.service.ISealDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 印章详细Controller
 *
 * @author ess
 * @date 2021-10-25
 */
@RestController
@RequestMapping("/seal/detail")
public class SealDetailController extends BaseController
{
    @Autowired
    private ISealDetailService sealDetailService;

    /**
     * 查询印章详细列表
     */
    @PreAuthorize("@ss.hasPermi('seal:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(SealDetail sealDetail)
    {
        startPage();
        List<SealDetail> list = sealDetailService.selectSealDetailList(sealDetail);
        return getDataTable(list);
    }

    /**
     * 导出印章详细列表
     */
    @PreAuthorize("@ss.hasPermi('seal:detail:export')")
    @Log(title = "印章详细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SealDetail sealDetail)
    {
        List<SealDetail> list = sealDetailService.selectSealDetailList(sealDetail);
        ExcelUtil<SealDetail> util = new ExcelUtil<SealDetail>(SealDetail.class);
        return util.exportExcel(list, "印章详细数据");
    }

    /**
     * 获取印章详细详细信息
     */
    @PreAuthorize("@ss.hasPermi('seal:detail:query')")
    @GetMapping(value = "/{sealDetailId}")
    public AjaxResult getInfo(@PathVariable("sealDetailId") String sealDetailId)
    {
        return AjaxResult.success(sealDetailService.selectSealDetailBySealDetailId(sealDetailId));
    }

    /**
     * 新增印章详细
     */
    @ApiOperation("新增印章详细")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "sealDetailId", value = "详细表主键ID", dataType = "String", required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "sealName", value = "印章名称", dataType = "String",  required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "sealImgId", value = "图片ID", dataType = "String",required = true,  dataTypeClass = String.class),
            @ApiImplicitParam(name = "sealCertId", value = "证书ID", dataType = "String",required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "sealTypeId", value = "印章类型", dataType = "String",required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "sealPersonId", value = "签名所属人", dataType = "String", required = true,dataTypeClass = String.class),
            @ApiImplicitParam(name = "sealStartTime", value = "有效期开始时间", dataType = "String",required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "sealEndTime", value = "有效期结束时间", dataType = "String",required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "isUk", value = "是否UK", dataType = "String",required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "sealStandard", value = "印章标准", dataType = "String",required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "ukType", value = "UK类型", dataType = "String",dataTypeClass = String.class),
            @ApiImplicitParam(name = "ukId", value = "UKID", dataType = "String", dataTypeClass = String.class)
    })
    @PreAuthorize("@ss.hasPermi('seal:detail:add')")
    @Log(title = "印章详细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SealDetail sealDetail)
    {
        return toAjax(sealDetailService.insertSealDetail(sealDetail));
    }

    /**
     * 修改印章详细
     */
    @PreAuthorize("@ss.hasPermi('seal:detail:edit')")
    @Log(title = "印章详细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SealDetail sealDetail)
    {
        return toAjax(sealDetailService.updateSealDetail(sealDetail));
    }

    /**
     * 删除印章详细
     */
    @PreAuthorize("@ss.hasPermi('seal:detail:remove')")
    @Log(title = "印章详细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sealDetailIds}")
    public AjaxResult remove(@PathVariable String[] sealDetailIds)
    {
        return toAjax(sealDetailService.deleteSealDetailBySealDetailIds(sealDetailIds));
    }
}
